package com.zzw.spring;

import java.text.DateFormat;
import java.text.MessageFormat;
import java.text.NumberFormat;
import java.util.Date;
import java.util.GregorianCalendar;
import java.util.Locale;
import java.util.ResourceBundle;

public class LocaleTest {

	public static void main(String[] args) {
		Locale locale1 = new Locale("zh","CN");
		Locale locale2 = new Locale("zh");
		Locale locale3 = Locale.CHINA;
		Locale locale4 = Locale.CHINESE;
		Locale locale5 = Locale.getDefault();
		NumberFormat format = NumberFormat.getCurrencyInstance(locale1);
		double amt = 12345.678;
		System.out.println(format.format(amt));
		
		Date date = new Date();
		DateFormat dateFormat = DateFormat.getDateInstance(DateFormat.MEDIUM,locale1);
		System.out.println(dateFormat.format(date));
		
		String pattern1 = "{0} ,你好! 你于{1}在工商银行存入{2}元。";
		String pattern2 = "At {1,time,short} On{1,date,long},{0} paid {2,number,currency}.";
		Object[] params = {"John",new GregorianCalendar().getTime(),1.0E3};
		
		String msg1 = MessageFormat.format(pattern1, params);
		
		MessageFormat mf = new MessageFormat(pattern2, Locale.US);
		String msg2 = mf.format(params);
		System.out.println(msg1);
		System.out.println(msg2);
	
		ResourceBundle bundle = ResourceBundle.getBundle("msg",Locale.CHINA);
		System.out.println(bundle.getString("hello"));
	}
}
